package icu.qx.common.constant;

import lombok.Getter;

import java.util.Arrays;

/**
 * @auther yong
 * @create 2023-12-22 15:45
 */

public enum TableNameEnum {
    WM_STORAGE_LOCATION("wm_storage_location", "库位"),
    GBS_GOOD_FILE("gbs_good_file", "物品附件"),
    WM_STORAGE_INFO("wm_storage_info", "库存信息"),
    WM_STORAGE_AREA("wm_storage_area", "库区"),
    WM_WAREHOUSE("wm_warehouse", "仓库"),
    GBS_GOOD("gbs_good", "物品 通过 is_material 区分物料和产品"),
    GBS_GOOD_URL("gbs_good_url", "物品图片"),
    DEV_DEVICE_IMG("dev_device_img", "设备图片"),
    PBS_PROCEDURE_ROUTE("pbs_procedure_route", "工艺路线"),
    GBS_GOOD_CLASs("gbs_good_class", "物品分类"),
    GBS_GOOD_UNIT("gbs_good_unit", "物品单位"),
    SYS_CODE("sys_code", "系统编号"),
    WM_PRODUCT_RECEIPT("wm_product_receipt", "产品入库单"),
    WM_RETURN_MATERIAL_LIST("wm_return_material_list", "生产退料物料清单"),
    QC_QUALITY_QPROJECT("qc_quality_qproject", "质检项目质检情况"),
    WM_PRODUCTION_REQUEST_DETAIL("wm_production_request_detail", "生产领料详情"),
    QC_DRAWBACK("qc_drawback", "缺陷"),
    PRO_WORK_TASK("pro_work_task", "工单任务"),
    PRO_WORK_REPORT("pro_work_report", "报工单"),
    PRO_WORK_PEO("pro_work_peo", "生产人员"),
    PRO_WORK_ORDER("pro_work_order", "生产工单"),
    PRO_PAUSE_REASON("pro_pause_reason", "生产工单暂停原因"),
    PBS_WORK_GROUP_PEO("pbs_work_group_peo", "生产班组成员"),
    PBS_WORK_GROUP("pbs_work_group", "生产班组"),
    PRO_SCHEDULE("pro_schedule", "生产计划"),
    PBS_PROCEDURE_MATERIAL("pbs_procedure_material", "工序物料清单"),
    PBS_PROUTE_PROCEDURE("pbs_proute_procedure", "工艺路线工序表"),
    PBS_WORK_CELL("pbs_work_cell", "生产单元"),
    DEV_REPAIR_IMG("dev_repair_img", "维修图片"),
    DEV_REPAIR_ORDER("dev_repair_order", "维修单"),
    DEV_REPAIR_REQUEST("dev_repair_request", "报修单"),
    GBS_BOM("gbs_bom", "BOM清单"),
    DEV_MAINTENANCE_ITEM("dev_maintenance_item", "保养项"),
    DEV_INSPECTION_SHEET("dev_inspection_sheet", "巡检单"),
    DEV_MAINTENANCE_SHEET("dev_maintenance_sheet", "保养单"),
    DEV_MAINTENANCE_PLAN("dev_maintenance_plan", "保养计划"),
    DEV_DEVICE_FILE("dev_device_file", "设备附件"),
    DEV_DEVICE_INFO("dev_device_info", "设备信息"),
    DEV_INSPECTION_ITEM("dev_inspection_item", "巡检项"),
    DEV_INSPECTION_PLAN("dev_inspection_plan", "巡检计划"),
    WM_SALES_OUTBOUND("wm_sales_outbound", "销售出库单"),
    WM_PRODUCTION_MATERIAL_REQUEST("wm_production_material_request", "生产领料"),
    WM_PRODUCTION_MATERIAL_RETURN2("wm_production_material_return2", "生产退料"),
    QC_RECEIPT_QUALITY("qc_receipt_quality", "入货检验单"),
    QC_DRAWBACK_TYPE("qc_drawback_type", "缺陷类型"),
    QC_OUTGOING_QUALITY("qc_outgoing_quality", "出货检验单"),
    QC_QUALITY_PROJECT("qc_quality_project", "质检项目"),
    QC_PRO_QUALITY("qc_pro_quality", "过程检验"),
    PBS_WORK_CELL_TYPE("pbs_work_cell_type", "生产单元类型"),
    PBS_PROCEDURE("pbs_procedure", "工序"),
    GBS_SALE_ORDER("gbs_sale_order", "销售订单"),
    PBS_GROUP_TYPE("pbs_group_type", "班组类型"),
    GBS_BOM_MATERIAL("gbs_bom_material", "物料配件"),
    DEV_MAINTENANCE_CONFIG("dev_maintenance_config", "保养配置"),
    DEV_INSPECTION_CONFIG("dev_inspection_config", "巡检配置"),
    DEV_DEVICE_TYPE("dev_device_type", "设备类型");

    private final String tableName; // 自定义的状态码
    private final String tableComment; // 自定义的描述信息

    TableNameEnum(String tableName, String tableComment) {
        this.tableName = tableName;
        this.tableComment = tableComment;
    }

    public String getTableName() {
        return tableName;
    }

    public String getTableComment() {
        return tableComment;
    }

    @Override
    public String toString() {
        return "TableNameEnum{" +
                "tableName='" + tableName + '\'' +
                ", tableComment='" + tableComment + '\'' +
                '}';
    }

    //3 遍历
    //3.1 传统版
    public static TableNameEnum gettableNameEnumV1(String tableName) {
        for (TableNameEnum element : TableNameEnum.values()) {
            if (element.getTableName().equalsIgnoreCase(tableName)) {
                return element;
            }
        }
        return null;
    }

    //3.2 Stream流式计算版
    public static TableNameEnum gettableNameEnumV2(String code) {
        return Arrays.stream(TableNameEnum.values()).filter(x -> x.getTableComment().equalsIgnoreCase(code)).findFirst().orElse(null);
    }
}
